package com.hk.common.runner;

import com.hk.common.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Calendar;
import java.util.Date;

/**
 * 定时任务操作
 * @author zy
 * @date 2023-09-04
 */
@Configuration
@EnableScheduling
public class PeriodRunner {

    private final Logger log = LoggerFactory.getLogger(PeriodRunner.class);



    /**
     * 执行定时任务 生成上月对账数据  1号凌晨1点执行
     */
    @Scheduled(cron = "0 0 1 1 * ?")
    private void createRecTask(){
        log.info("执行定时【同步结算数据】任务，执行时间:"+ DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        // 生成对账任务
        Date date = new Date();
        date = DateUtils.add(date, Calendar.MONTH,-1);
        Date startDate = DateUtils.curMonthStartDate(date);
        Date endDate = DateUtils.curMonthEndDate(date);
    }


    /**
     * 每天晚上十点点都 执行检查结付信息
     */
    @Scheduled(cron = "0 0 22 * * ?")
    private void executeRecTask(){
        log.info("执行定时【检查结付信息】任务操作"+ DateUtils.format(new Date(),"yyyy-MM-dd hh:mm:ss"));
        // 生成对账任务
        String setlMon = DateUtils.getLastSetlMon(new Date());
    }
}
